/*
 * @Author: syyao 
 * @Date: 2019-05-17 15:24:07 
 * @Last Modified by: syyao
 * @Last Modified time: 2019-06-10 21:06:10
 */
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: {
      info: {
        nickname: "",
        picture: "",
        birth: "",
        sex: ""
      },
      Hub: [],
      starId:'',
      choosenPHubId: '',
      isLogin: false,
    },
    loginFilter: false,
    visitorFilter:{
      state:false,
      id:''
    }
  },
  mutations: {
    setUserInfo(state, info) {
      state.user.info = info;
      state.user.isLogin = true;
    },
    setUserHub(state, hub) {
      state.user.Hub = hub
    },
    setUserStarId(state,info){
      state.user.starId=info
    },
    setUserImg(state, picture) {
      state.user.info.img = picture;
    },
    setUserOther(state, info) {
      state.user.info.nickname = info.nickname;
      state.user.info.birth = info.birth;
    },
    setLoginFilter(state) {
      state.loginFilter = true;
      setTimeout(() => {
        state.loginFilter=false
    }, 200)
    },
    setVisitorFilter(state,info){
      state.visitorFilter.id=info
      state.visitorFilter.state=true
      setTimeout(() => {
        state.visitorFilter.state=false
    }, 200)
    },
    setChoosenHubId(state, id) {
      state.user.choosenPHubId = id;
    },
    clearAll(state) {
      state.user = {
        info: {
          nickname: "",
          picture: "",
          birth: "",
          sex: ""
        },
        Hub: [],
        choosenPHubId: '',
        isLogin: false
      };
      state.loginFilter = false;
    }

  },
  actions: {

  }
})